package com.fr.data.impl;

import com.fr.base.FRContext;
import com.fr.base.XMLable;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.FRCoreContext;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.AbstractTableData;
import com.fr.data.TableData;
import com.fr.data.TableDataException;
import com.fr.report.parameter.Parameter;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ClassTableData extends AbstractTableData
  implements XMLable
{
  private String className;
  private TableData _tableData = null;

  public ClassTableData()
  {
  }

  public ClassTableData(String paramString)
  {
    setClassName(paramString);
  }

  public String getClassName()
  {
    return this.className;
  }

  public void setClassName(String paramString)
  {
    this.className = paramString;
  }

  private TableData createTableData()
  {
    if (this._tableData == null)
      try
      {
        this._tableData = ((TableData)FRCoreContext.classForName(getClassName()).newInstance());
      }
      catch (Exception localException)
      {
        FRContext.getLogger().log(Level.WARNING, "ClassName: " + getClassName());
        FRContext.getLogger().log(Level.WARNING, localException.getMessage(), localException);
        this._tableData = TableData.EMPTY_TABLEDATA;
      }
    return this._tableData;
  }

  public int getColumnCount()
    throws TableDataException
  {
    return createTableData().getColumnCount();
  }

  public String getColumnName(int paramInt)
    throws TableDataException
  {
    String str = createTableData().getColumnName(paramInt);
    return str;
  }

  public int getRowCount()
    throws TableDataException
  {
    return createTableData().getRowCount();
  }

  public Object getValueAt(int paramInt1, int paramInt2)
    throws TableDataException
  {
    return createTableData().getValueAt(paramInt1, paramInt2);
  }

  public Parameter[] getParameters()
  {
    return createTableData().getParameters();
  }

  public void release()
    throws Exception
  {
    createTableData().release();
  }

  public String toString()
  {
    return "ClassTableData[Class:" + getClassName() + "]";
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof ClassTableData) && (super.equals(paramObject)) && (ComparatorUtils.equals(this.className, ((ClassTableData)paramObject).className)));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return new ClassTableData(getClassName());
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("ClassTableDataAttr")))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("className")) != null)
        setClassName(str);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("ClassTableDataAttr").attr("className", getClassName()).end();
  }
}